#include"lexical_component.h"

const char* ComponentString[] = {
    //default
    "\0",
    //comment marks
    "/*",
    "*/",
    "//",
    //brackets
    "{",
    "}",
    "[",
    "]",
    "(",
    ")",
    //binary operators
    "+",
    "-",
    "*",
    "/",
    "%",
    "==",
    "!=",
    ">",
    "<",
    ">=",
    "<=",
    "&&",
    "||",
    "&",
    "|",
    "^",
    //unary operator
    "~",
    "!",
    "++",
    "--",
    //assignment
    "=",
    "+=",
    "-=",
    "*=",
    "/=",
    "%=",
    "&=",
    "|=",
    "^=",
    //special
    ".",
    ",",
    ";",
    ":",
    "#",
    "?",
    "<<",
    ">>",
    //keywords
    "auto",
    "break",
    "bool",
    "case",
    "char",
    "const",
    "continue",
    "default",
    "do",
    "double",
    "else",
    "enum",
    "extern",
    "float",
    "for",
    "goto",
    "if",
    "int",
    "long",
    "register",
    "return",
    "short",
    "signed",
    "sizeof",
    "static",
    "struct",
    "switch",
    "typedef",
    "union",
    "unsigned",
    "void",
    "volatile",
    "while",
    //ID
    "\0\0\0\0\0",
    //constants
    "true",
    "false",
    "\0\0",
    "\0\0\0",
    "\0\0\0\0"
};

const char* ComponentName[] = {
    //default
    "Undefined",
    //comment marks
    "MultipleLineCommentLeft",
    "MultipleLineCommentRight",
    "SingleLineComment",
    //brackets
    "LeftBrace",
    "RightBrace",
    "LeftSquareBracket",
    "RightSquareBracket",
    "LeftBracket",
    "RightBracket",
    //binary operators
    "Plus",
    "Minus",
    "Multiply",
    "Divide",
    "Modulus",
    "Equal",
    "NotEqual",
    "Greater",
    "Less",
    "GreaterEqual",
    "LessEqual",
    "LogicalAnd",
    "LogicalOr",
    "BinaryAnd",
    "BinaryOr",
    "BinaryXor",
    //unary operators
    "BinaryNot",
    "LogicalNot",
    "Increment",
    "Decrement",
    //assignment
    "Assignment",
    "AddAssignment",
    "SubtractAssignment",
    "MultiplyAssignment",
    "DivideAssignment",
    "ModulusAssignment",
    "BinaryAndAssignment",
    "BinaryOrAssignment",
    "BinaryXorAssignment",
    //special
    "Dot",
    "Comma",
    "Semicolon",
    "Colon",
    "NumberSign",
    "QuestionMark",
    "LeftShift",
    "RightShift",
    //keywords
    "Auto",
    "Break",
    "Bool",
    "Case",
    "Char",
    "Const",
    "Continue",
    "Default",
    "Do",
    "Double",
    "Else",
    "Enum",
    "Extern",
    "Float",
    "For",
    "Goto",
    "If",
    "Int",
    "Long",
    "Register",
    "Return",
    "Short",
    "Signed",
    "Sizeof",
    "Static",
    "Struct",
    "Switch",
    "Typedef",
    "Union",
    "Unsigned",
    "Void",
    "Volatile",
    "While",
    //ID
    "ID",
    //constants
    "True",
    "False",
    "ConstString",
    "ConstChar",
    "Digit"
};

bool is_undefined(LexComponent i) { return i == LexComponent::Undefined; }
bool is_comment_mark(LexComponent i) { return i >= LexComponent::MultipleLineCommentLeft && i <= LexComponent::SingleLineComment; }
bool is_bracket(LexComponent i) { return i >= LexComponent::LeftBrace && i <= LexComponent::RightBracket; }
bool is_binary_operator(LexComponent i) { return i >= LexComponent::Plus && i <= LexComponent::BinaryXor; }
bool is_unary_operator(LexComponent i) { return i >= LexComponent::BinaryNot && i <= LexComponent::Decrement; }
bool is_assignment(LexComponent i) { return i >= LexComponent::Assignment && i <= LexComponent::BinaryXorAssignment; }
bool is_id(LexComponent i) { return i == LexComponent::ID; }
bool is_constant(LexComponent i) { return i >= LexComponent::True && i <= LexComponent::Digit; }